<?php

namespace app\admin\controller;

use app\common\controller\Backend;


/**
 * 平台设置
 * @internal
 */
class Systemset extends Backend
{



    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Systemset');
    }

    public function index() {
        if ($this->request->isGet()){
            $row['public_appid'] = $this->model->where('key','public_appid')->value('val');
            $row['token'] = $this->model->where('key','token')->value('val');
            $row['public_appsecret'] = $this->model->where('key','public_appsecret')->value('val');
            $this->assign('row',$row);
        }else{
            $params = $this->request->post("row/a");
            foreach ($params as $k=>$v){
                $this->model->where('key',$k)->update([
                    'val'=>$v
                ]);
            }
            return $this->success('更新成功!');
        }
        return $this->view->fetch();
    }

}
